package squareBorderPackage;

public class Wall extends Border {

	/**
	 * Initialize this new wall with given slippery.
	 * 
	 * @param slippery
	 *            The initial value for the slippery state of this new wall.
	 */
	public Wall(boolean slippery, Square[] squares,
			Direction directionOfFirstSquare) {
		super(squares, directionOfFirstSquare);
		this.slippery = slippery;
	}
	
	public Wall(boolean slippery, Square square, Direction direction) {
		super(square, direction);
		this.slippery = slippery;
	}

	/**
	 * Return whether this wall is slippery or not.
	 */
	public boolean getSlippery() {
		return slippery;
	}

	/**
	 * Variable registering whether the door is slippery or not.
	 */
	public final boolean slippery;

	/**
	 * Return whether this wall is an obstacle or not.
	 * 
	 * @return result==true;
	 */
	public boolean isObstacle() {
		return true;
	}

	/**
	 * @return This border if the other border is not effective | if (other ==
	 *         null) | then (result == this)
	 * @return The other border if the other border is a wall and this wall is
	 *         slippery. |if (other instanceof Wall && this.getSlippery()) |
	 *         then (result == other)
	 * @return This border if the other Border is a wall and this wall is not
	 *         slippery |if (other instanceof Wall && ! this.getSlippery()) |
	 *         then (result == this)
	 * @return This border if the other border is a open border. |if (other
	 *         instanceof OpenBorder) | then (result == this)
	 * @return This border if the other border is a door. |if (other instanceof
	 *         Door) | then (result == this)
	 * @return The strongest border of the other border and this border in all
	 *         other cases. |if (! (other == null || | other instanceof Wall ||
	 *         | other instanceof OpenBorder || | other instanceof Door)) | then
	 *         (result == other.getStrongestBorder(this)
	 */
	@Override
	public Border getStrongestBorder(Border other) {
		if (other == null)
			return this;
		if (other instanceof Wall) {
			if (this.getSlippery())
				return other;
			return this;
		}
		if (other instanceof OpenBorder)
			return this;
		if (other instanceof Door)
			return this;
		return other.getStrongestBorder(this);
	}

}
